home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Misc / Wood.0.72 / Sources / UndoManager.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-29  |  3.8 KB  |  126 lines

  1. #import <appkit/appkit.h>
  2. //  Written by: Jeff Martin (jmartin@bozell.com)
  3. //  You may freely copy, distribute and reuse the code in this example.  
  4. //  Don't even talk to me about warranties.
  5.  
  6. @interface UndoManager : Object
  7. {
  8.     id    undoList;    // The list that holds undo records
  9.     id    redoList;    // The list that holds redo records
  10.     int    disabled;    // Whether the UndoManager is accepting events
  11.     BOOL    undoing;    // Whether the UndoManager is currently undoing
  12.     BOOL    redoing;    // Whether the UndoManager is currently redoing
  13.     BOOL    recordGrouping;    // Whether UndoRecords are being grouped
  14.     int    levelsOfUndo;    // How many levels of undo/redo to record
  15.  
  16.     id    target;        // Current target of registered undo messages
  17.     unsigned int    freeArgsMask;    // Stores which args to free
  18.     unsigned int    copyArgsMask;    // Make undo manager copy pointer args
  19.     char *undoName;
  20.     char *redoName;
  21.     id    delegateList;    // List of objects to be notified of UM changes
  22. }
  23.  
  24. // Format of an undo/redo record
  25. typedef struct UndoRecord {
  26.     marg_list args;
  27.     int freeArgsMask;
  28.     int argSize;
  29. } UndoRecord;
  30.  
  31. typedef struct RecordGroup {
  32.     Storage *recordList;
  33.     char *undoName;
  34.     char *redoName;
  35. } RecordGroup;
  36.  
  37.  
  38. - init;
  39.  
  40. // Grouping multiple UndoRecords into an undo event
  41. - beginUndoRecordGrouping;
  42. - endUndoRecordGrouping;
  43.  
  44. // Disable/Reenable UndoManager to prevent events from being added to undo list
  45. - disableUndoRegistration;
  46. - reenableUndoRegistration;
  47.  
  48. // Setting the current target for events that are received
  49. - setUndoTarget:object;
  50.  
  51. // Setting the current name of RecordGroup
  52. - setUndoName:(const char *)aName;
  53. - setRedoName:(const char *)aName;
  54.  
  55. // Querying the Undo/Redo status for menu validation
  56. - (const char *)lastUndoName;
  57. - (const char *)lastRedoName;
  58.  
  59. // Setting the target or args of the next registered method to be freed when 
  60. //  they fall off the end of the undo/redo list or are executed
  61. - freeUndoTarget;
  62. - freeUndoArgs;
  63. - freeUndoArgAt:(int)pos;
  64.  
  65. // Setting the target or args of the next registered method to be freed when 
  66. //  they fall off the end of the undo/redo list
  67. - freeUndoTargetOnRecordDiscard;
  68. - freeUndoArgsOnRecordDiscard;
  69. - freeUndoArgOnRecordDiscardAt:(int)pos;
  70.  
  71. // Setting the target or args of the next registered method to be freed when 
  72. //  they are executed
  73. - freeUndoTargetOnRecordExecute;
  74. - freeUndoArgsOnRecordExecute;
  75. - freeUndoArgOnRecordExecuteAt:(int)pos;
  76.  
  77. // Make UndoManager copy arguments(like objects or strings) for convenience
  78. - copyUndoArgs;
  79. - copyUndoArgAt:(int)pos;
  80.  
  81. // Make UndoManager copy arguments and free them when record is discarded
  82. - copyUndoArgsFreeOnDiscard;
  83. - copyUndoArgFreeOnDiscardAt:(int)pos;
  84.  
  85. // Make UndoManager copy arguments and free them when record is executed
  86. - copyUndoArgsFreeOnExecute;
  87. - copyUndoArgFreeOnExecuteAt:(int)pos;
  88.  
  89. // Copies the pointer args in undoRecord as requested by copyArgsMask
  90. - copyUndoArgsForRecord:(UndoRecord *)undoRecord;
  91.  
  92. // Overridden to capture undo/redo messages to be added to current record
  93. - forward:(SEL)aSelector :(marg_list)argFrame;
  94.  
  95. // Removes a record from the undo/redo list and dispatches the messages in it.
  96. - undo:sender;
  97. - redo:sender;
  98.  
  99. // Query and set the maximum length of the undo/redo list
  100. - (int)levelsOfUndo;
  101. - setLevelsOfUndo:(int)value;
  102.  
  103. // These methods add and remove objects that are to receive undo notification.
  104. - addUndoDelegate:object;
  105. - removeUndoDelegate:object;
  106. - sendNotification:(SEL)action;
  107.  
  108. // Used internally to free the space used for an undo/redo groups and records
  109. - discardRecordGroup:(RecordGroup *)group;
  110. - executeRecordGroup:(RecordGroup *)group;
  111. - freeUndoRecord:(UndoRecord *)undoRecord withFreeMask:(int)mask;
  112.  
  113. // Remove and Free all records currently stored in the UndoManager 
  114. - emptyUndoManager;
  115.  
  116. // Free space used by UndoManager
  117. - free;
  118.  
  119. @end
  120.  
  121. extern id undoManager;
  122.  
  123. @protocol UndoDelegate
  124. - undoManagerWillUndo:sender;
  125. - undoManagerDidUndo:sender;
  126. @end